// 1.加载核心模块
const http=require("http");
const router=require("./router");


// 2.创建服务器功能函数
const server=http.createServer(function(request,response){
    let path=request.url;//请求路径 /aaaa   /user
    // console.log(router);//对象{ "/user":userApi.findUser,"/user2":userApi.findUsers, "/userList":userApi.findList,"/userList2":userApi.findList2}
   
    let fun=router[path];//undefined
    let str=fun?fun():"<h2>404</h2>";
    response.end(str);
        
    
   
}); 


// 3.启动服务器
server.listen(3000);
